package com.itlaobing.demo.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Classname PageServlet
 * @Description TODO()
 * @Date 2020/11/11 0011 11:11
 * @Author by Administrator
 * @Version v1.0
 */
@WebServlet(urlPatterns = "/page")
public class PageServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //  xxx/page?action=index
        String action = req.getParameter("action");
        if (action == null || "".equals(action)){
            resp.sendRedirect("login.jsp");
        }else{
            //WEB-INF/pages/sys/header.jsp
            // 请求转发
            req.getRequestDispatcher("WEB-INF/pages/" + action + ".jsp").forward(req, resp);
        }
    }
}
